<template>
	<view class="pageBox">
		<view class="list">
			<view class="listItem" v-for="item in list" :key="item.id">
				<view class="item">
					钱包：{{ item.creditName }}
				</view>
				<view class="item">
					数量：{{ item.num }}
				</view>
				
				<view class="item">
					时间：{{ item.createdAt }}
				</view>
				
				<view class="item">
					备注：{{ item.remark }}
				</view>
			</view>
		</view>
		<uni-load-more :status="listStatus"></uni-load-more>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				form: {
					page: 1,
					lastId: 0,
				},
				loading: false,
				finished: false,
			}
		},
		onShow() {
			this.list = [];
			this.form.page = 1;
			this.form.lastId = 0;
			this.loading = false;
			this.finished = false;
			this.getList();
		},
		onReachBottom() {
			this.getList();
		},
		computed: {
			listStatus() {
				if (this.finished) return "noMore";
				if (this.loading) return "loading";
				return "more";
			}
		},
		methods: {
			getList() {
				if (this.loading || this.finished) return;
				this.loading = true;
				this.$post({
					module: 'Finance',
					interface: 2100,
					data: {
						creditType: 'credit_3',
						...this.form
					},
				}).then(res => {
					this.list = this.list.concat(res.list);
					this.form.page = res.currentPage + 1;
					this.form.lastId = res.lastId;
					if (this.form.page > res.lastPage) {
						this.finished = true;
					}
					this.loading = false;
				}).catch(() => {
					this.loading = false;
				})
			},
		},
	}
</script>

<style scoped lang="scss">
	.pageBox {
		width: 100%;
		min-height: calc(100vh - var(--window-top));
		background-color: #f9f9f9;
	}
	.list {
		padding: 32rpx 32rpx 0;
		.listItem {
			padding: 32rpx;
			border-radius: 16rpx;
			background-color: #ffffff;
			margin-bottom: 32rpx;
			.item {
				font-size: 32rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #000000;
				line-height: 44rpx;
				padding: 10rpx 0;
			}
		}
	}
</style>